<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>

    <script>
      function fun1() {
        console.log("按键按下了");
      }
      function fun2() {
        console.log("按键抬起了");
      }
    </script>
  </head>
  <body>
    
    <input type = "text" onkeydown="fun1()" onkeyup = "fun2()";>

  </body>
</html>
